package cn.flying.base.process.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import cn.flying.base.process.model.CfProcNode;

/**
 * @description: 流程节点mapper
 * @author: lvyong
 * @date: 2023年02月23日 10:24
 * @version: 1.0
 */
@Mapper
public interface ProcessNodeMapper {

    /**
     * 保存
     *
     * @param bpmnNode
     */
    @Insert("insert into cf_proc_node (id,proc_def_id,proc_def_key,node_id,node_name,node_type,version,remark,tenant_id,revision,created_by,created_time,updated_by,updated_time,del_flag)" +
            "values (#{id}, #{procDefId}, #{procDefKey}, #{nodeId}, #{nodeName}, #{nodeType}, #{version}, #{remark}, #{tenantId}, #{revision}, #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime}, #{delFlag})")
    void insert(CfProcNode procNode);

    /**
     * 查询流程节点
     *
     * @return
     */
    @Select("select id,proc_def_id,proc_def_key,node_id,node_name,node_type,version,remark,tenant_id from cf_proc_node where proc_def_id=#{procDefId}}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "procDefId", column = "proc_def_id"),
            @Result(property = "procDefKey", column = "proc_def_key"),
            @Result(property = "nodeId", column = "node_id"),
            @Result(property = "nodeName", column = "node_name"),
            @Result(property = "nodeType", column = "node_type"),
            @Result(property = "version", column = "version"),
            @Result(property = "remark", column = "remark"),
            @Result(property = "tenantId", column = "tenant_id"),
            @Result(property = "revision", column = "revision"),
    })
    CfProcNode getProcBpmnNode(String procDefId);
}

